package com.example.childrendapp.login;

import java.io.IOException;

import com.example.childrendapp.R;
import com.example.childrendapp.database.DataBaseHelper;

import android.app.Activity;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnCreateContextMenuListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class Register extends Activity implements OnClickListener{
	private EditText mName;
	private EditText mPass;
	private Button mRegister;
	private DataBaseHelper mDB;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		this.setContentView(R.layout.register_xml);
		mDB = new DataBaseHelper(this);
		mName=(EditText) findViewById(R.id.txtUser);
		mPass=(EditText) findViewById(R.id.txtPass);
		mRegister=(Button) findViewById(R.id.btnRegister);
		mRegister.setOnClickListener(this);
		
		
	}
	@Override
	public void onClick(View v) {

		mDB.Add(mName.getText().toString(), mPass.getText().toString());
        
        Toast.makeText(getApplicationContext(), "Record Saved!", Toast.LENGTH_SHORT).show();
		Intent i=new Intent();
		i.putExtra("NAME", mName.getText().toString());
		i.putExtra("PASS", mPass.getText().toString());
		this.setResult(RESULT_OK, i);
		this.finish();
		
	}
}
